﻿using UnityEngine;

public class PlayerAction : MonoBehaviour
{
    protected Animator anim;//animation controller 动画文件
    protected ThirdPersonSolution thirdControl;

    void Start()
    {
        anim = GetComponent<Animator>();
        thirdControl = transform.parent.parent.gameObject.GetComponent<ThirdPersonSolution>();
    }

    void Update()
    {
        if (anim && thirdControl)
        {
            //状态捕获
            if (thirdControl.isMoving)
            {
                anim.SetBool("walking", true);
            }
            else
            {
                anim.SetBool("walking", false);
            }

            if (thirdControl.isAttacking)
            {
                anim.SetBool("attacking", true);
            }
            else
            {
                anim.SetBool("attacking", false);
            }
        }
    }
}
